{
    "nbformat": 4,
    "nbformat_minor": 2,
    "metadata": {
        "language_info": {
            "name": "python",
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "version": "3.8.1-final"
        },
        "orig_nbformat": 2,
        "file_extension": ".py",
        "mimetype": "text/x-python",
        "name": "python",
        "npconvert_exporter": "python",
        "pygments_lexer": "ipython3",
        "version": 3
    },
    "cells": [
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Install ipyvolume\n",
                "pip install ipyvolume"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 11,
            "metadata": {},
            "outputs": [
            ],
            "source": [
                "import ipyvolume as ipv\n",
                "import numpy as np\n",
                "x, y, z, u, v, w = np.random.random((6, 1000))*2-1\n",
                "selected = np.random.randint(0, 1000, 100)\n",
                "ipv.figure()\n",
                "quiver = ipv.quiver(x, y, z, u, v, w, size=5, size_selected=8, selected=selected)\n",
                "\n",
                "from ipywidgets import FloatSlider, ColorPicker, VBox, jslink\n",
                "size = FloatSlider(min=0, max=30, step=0.1)\n",
                "size_selected = FloatSlider(min=0, max=30, step=0.1)\n",
                "color = ColorPicker()\n",
                "color_selected = ColorPicker()\n",
                "jslink((quiver, 'size'), (size, 'value'))\n",
                "jslink((quiver, 'size_selected'), (size_selected, 'value'))\n",
                "jslink((quiver, 'color'), (color, 'value'))\n",
                "jslink((quiver, 'color_selected'), (color_selected, 'value'))\n",
                "VBox([ipv.gcc(), size, size_selected, color, color_selected])"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 12,
            "metadata": {},
            "outputs": [],
            "source": [
                "\n",
                "import ipyvolume as ipv\n",
                "import numpy as np"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 13,
            "metadata": {},
            "outputs": [],
            "source": [
                "\n",
                "s = 1/2**0.5\n",
                "# 4 vertices for the tetrahedron\n",
                "x = np.array([1.,  -1, 0,  0])\n",
                "y = np.array([0,   0, 1., -1])\n",
                "z = np.array([-s, -s, s,  s])\n",
                "# and 4 surfaces (triangles), where the number refer to the vertex index\n",
                "triangles = [(0, 1, 2), (0, 1, 3), (0, 2, 3), (1,3,2)]"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 14,
            "metadata": {},
            "outputs": [
            ],
            "source": [
                "ipv.figure()\n",
                "# we draw the tetrahedron\n",
                "mesh = ipv.plot_trisurf(x, y, z, triangles=triangles, color='orange')\n",
                "# and also mark the vertices\n",
                "ipv.scatter(x, y, z, marker='sphere', color='blue')\n",
                "ipv.xyzlim(-2, 2)\n",
                "ipv.show()"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": []
        }
    ]
}
